package com.sky.test;

import com.sky.utils.JwtUtil;
import io.jsonwebtoken.Claims;
import org.junit.jupiter.api.Test;
import org.springframework.boot.test.context.SpringBootTest;

import java.io.UnsupportedEncodingException;
import java.util.HashMap;
public class CreateJwt {

    @Test
    public void createJwt() throws UnsupportedEncodingException {
        HashMap<String, Object> claims = new HashMap<>();
        claims.put("你好", "1234567890");
        String jwt = JwtUtil.createJWT("123456", 7200000L, claims);
        System.out.println(jwt);
    }
    @Test
    public void parseJwt() {
     String token = "eyJhbGciOiJIUzI1NiJ9.eyLkvaDlpb0iOiIxMjM0NTY3ODkwIiwiZXhwIjoxNzI2MjA3OTkzfQ.wjDSPDGC4_b4s6LHT6-pvGdOm8t6C7IGER0usDcgSN0";
        String secretKey = "123456";
        Claims claims = JwtUtil.parseJwt(secretKey, token);
        System.out.println(claims);
    }
}
